﻿@model GoPlay.Models.Team

@{
    ViewBag.Title = "Details";
}

<h2>@Html.DisplayFor(model => model.Name)</h2>

@if (Session["FlashSuccess"] != null)
    {
        <div class="alert alert-success">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <h4>Success</h4>
            @Session["FlashSuccess"]
            @{
                Session["FlashSuccess"] = null;
            }
        </div>
    }

@if (Session["FlashError"] != null)
    {
        <div class="alert alert-error">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <h4>Oops</h4>
            @Session["FlashError"]
            @{
                Session["FlashError"] = null;
            }
        </div>
    }

   
        <div class="row">
            <div class="span6 well">    
                <h4>Games</h4> 
                <table class="table">
                    <thead>
                        <tr>
                            <td>Decision</td><td>GF</td><td>GA</td><td>Date and Time</td><td></td>
                        </tr>
                    </thead>
                    @foreach (var g in Model.Games)
                    {
                        <tr>
                            <td>@g.Decision</td>
                            <td>@g.GF</td>
                            <td>@g.GA</td>
                            <td>@g.Date @g.Time</td>
                            <td>
                                @Html.RouteLink("[Edit]", "Games", new { TeamId = g.TeamId, controller = "Games", id = g.Id, action="Edit" }) | 
                                @Html.RouteLink("[Delete]", "Games", new { TeamId = g.TeamId, controller = "Games", id = g.Id, action="Delete" })
                            </td>
                        </tr>
                    }
                </table>
                <p>
                    @Html.RouteLink("Add a game", "Games", new { TeamId = Model.Id, controller = "Games", action="Create" }, new { @class="btn btn-success"})
                </p>
                
            </div>
            <div class="span5 well">     
                <h4>Players</h4>
                <table class="table">
                    <thead>
                        <tr>
                            <td>Player</td><td>G</td><td>A</td><td>P</td>
                        </tr>
                    </thead>
                    @foreach (var p in Model.Players)
                    {
                        <tr>
                            <td>@p.Contact.Name</td>
                            <td>@p.Goals</td><td>@p.Assists</td><td>@p.Points</td>
                            <td>
                                @Html.RouteLink("[Edit]", "Games", new { TeamId = p.TeamId, controller = "Players", id = p.Id, action="Edit" }) | 
                                @Html.RouteLink("[Delete]", "Games", new { TeamId = p.TeamId, controller = "Players", id = p.Id, action="Delete" })
                            </td>
                        </tr>
                    }
                </table>
                <p>
                    @Html.RouteLink("Add a player", "Players", new { TeamId = Model.Id, controller = "Players", action="Create" }, new { @class="btn btn-success"})
                </p>
                 
            </div>
        </div>




<p>
    @Html.ActionLink("Edit", "Edit", new { id=Model.Id }) |
    @Html.ActionLink("Back to List", "Index")
</p>
